package com.wt.test.ai.springai.controller;

import com.wt.test.ai.springai.service.ChatService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天控制器
 *
 * @author qiyu
 * @since 2025/1/25
 */
@RestController
@RequestMapping("/chat")
@RequiredArgsConstructor
@Slf4j
public class ChatController {
    
    private final ChatService chatService;
    
    /**
     * 聊天
     *
     * @param chatId  聊天ID
     * @param message 聊天内容
     * @return 聊天结果
     */
    @RequestMapping("/conversation")
    public String conversation(@RequestParam("chatId") String chatId,
                               @RequestParam("message") String message,
                               @RequestParam(value = "voice", required = false, defaultValue = "周星驰") String voice) {
        log.info("receive message: {}", message);
        return chatService.conversation(chatId, message, voice);
    }
}
